<template>
  <el-container class="setting_shopping-mall_inventory-set">
    <el-main>
      <div class="wrapper-box">
        <div class="dis">
          <div class="fin-setting-content">
            <el-card shadow="never" class="cardInfo">
              <div class="bg-white-panel">日志参数设置</div>
              <div class="dis al_item">
                <div class="nav-item">
                  <div class="dis al_item dis_ju_spb item-header">
                    <div class="cursor flex_1 dis al_item">
                      <el-form>
                        <el-form-item class="person-center-form-item">
                          <span class="form-item-title">管理用户日志保留时长：</span>
                          <el-input-number v-model="params.settingBase.tenantUserLogSaveYears" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="年" size="mini" />
                          <span class="form-item-title">年</span>
                          <el-input-number v-model="params.settingBase.tenantUserLogSaveMonths" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="月" size="mini" />
                          <span class="form-item-title">月</span>
                          <el-input-number v-model="params.settingBase.tenantUserLogSaveDays" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="天" size="mini" />
                          <span class="form-item-title">天</span>
                        </el-form-item>
                      </el-form>
                    </div>
                  </div>
                  <div class="dis al_item dis_ju_spb item-header">
                    <div class="cursor flex_1 dis al_item">
                      <el-form>
                        <el-form-item class="person-center-form-item" style="margin-left: 165px;">
                          <el-input-number v-model="params.settingBase.tenantUserNotLoginNotifyDays" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="年" size="mini" />
                          <span class="form-item-title">天未登录，提醒用户，提醒方式：</span>
                          <el-checkbox-group v-model="params.settingBase.tenantUserNotLoginNotifyChannels" style="float: right;">
                            <el-checkbox :label="1">短信</el-checkbox>
                            <el-checkbox :label="2">邮件</el-checkbox>
                            <el-checkbox :label="3">微信</el-checkbox>
                          </el-checkbox-group>
                        </el-form-item>
                      </el-form>
                    </div>
                  </div>
                </div>
              </div>
            </el-card>

            <el-card shadow="never" class="cardInfo">
              <div class="bg-white-panel">日志参数设置</div>
              <div class="dis al_item">
                <div class="nav-item">
                  <div class="dis al_item dis_ju_spb item-header">
                    <div class="cursor flex_1 dis al_item">
                      <el-form>
                        <el-form-item class="person-center-form-item">
                          <span class="form-item-title">管理用户日志保留时长：</span>
                          <el-input-number v-model="params.settingBase.tenantUserLogSaveYears" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="年" size="mini" />
                          <span class="form-item-title">年</span>
                          <el-input-number v-model="params.settingBase.tenantUserLogSaveMonths" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="月" size="mini" />
                          <span class="form-item-title">月</span>
                          <el-input-number v-model="params.settingBase.tenantUserLogSaveDays" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="天" size="mini" />
                          <span class="form-item-title">天</span>
                        </el-form-item>
                      </el-form>
                    </div>
                  </div>
                  <div class="dis al_item dis_ju_spb item-header">
                    <div class="cursor flex_1 dis al_item">
                      <el-form>
                        <el-form-item class="person-center-form-item">
                          <el-input-number v-model="params.settingBase.tenantUserNotLoginNotifyDays" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="年" size="mini" />
                          <span class="form-item-title">天未登录，提醒用户，提醒方式：</span>
                          <el-checkbox-group v-model="params.settingBase.tenantUserNotLoginNotifyChannels" style="float: right;">
                            <el-checkbox :label="1">短信</el-checkbox>
                            <el-checkbox :label="2">邮件</el-checkbox>
                            <el-checkbox :label="3">微信</el-checkbox>
                          </el-checkbox-group>
                        </el-form-item>
                      </el-form>
                    </div>
                  </div>
                </div>
              </div>
              <div class="dis al_item">
                <div class="nav-item">
                  <div class="dis al_item dis_ju_spb item-header">
                    <div class="cursor flex_1 dis al_item">
                      <el-form>
                        <el-form-item class="person-center-form-item">
                          <span class="form-item-title">商户用户日志保留时长：</span>
                          <el-input-number v-model="params.settingBase.shopUserLogSaveYears" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="年" size="mini" />
                          <span class="form-item-title">年</span>
                          <el-input-number v-model="params.settingBase.shopUserLogSaveMonths" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="月" size="mini" />
                          <span class="form-item-title">月</span>
                          <el-input-number v-model="params.settingBase.shopUserLogSaveDays" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="天" size="mini" />
                          <span class="form-item-title">天</span>
                        </el-form-item>
                      </el-form>
                    </div>
                  </div>
                  <div class="dis al_item dis_ju_spb item-header">
                    <div class="cursor flex_1 dis al_item">
                      <el-form>
                        <el-form-item class="person-center-form-item" style="margin-left: 165px;">
                          <el-input-number v-model="params.settingBase.shopUserNotLoginNotifyDays" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="年" size="mini" />
                          <span class="form-item-title">天未登录，提醒用户，提醒方式：</span>
                          <el-checkbox-group v-model="params.settingBase.shopUserNotLoginNotifyChannels" style="float: right;">
                            <!-- 1短信 2邮件 3微信 -->
                            <el-checkbox :label="1">短信</el-checkbox>
                            <el-checkbox :label="2">邮件</el-checkbox>
                            <el-checkbox :label="3">微信</el-checkbox>
                          </el-checkbox-group>
                        </el-form-item>
                      </el-form>
                    </div>
                  </div>
                </div>
              </div>
              <div class="dis al_item">
                <div class="nav-item">
                  <div class="dis al_item dis_ju_spb item-header">
                    <div class="cursor flex_1 dis al_item">
                      <el-form>
                        <el-form-item class="person-center-form-item">
                          <span class="form-item-title">会员用户日志保留时长：</span>
                          <el-input-number v-model="params.settingBase.memberLogSaveYears" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="年" size="mini" />
                          <span class="form-item-title">年</span>
                          <el-input-number v-model="params.settingBase.memberLogSaveMonths" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="月" size="mini" />
                          <span class="form-item-title">月</span>
                          <el-input-number v-model="params.settingBase.memberLogSaveDays" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="天" size="mini" />
                          <span class="form-item-title">天</span>
                        </el-form-item>
                      </el-form>
                    </div>
                  </div>
                </div>
              </div>
              <div class="dis al_item">
                <div class="nav-item">
                  <div class="dis al_item dis_ju_spb item-header">
                    <div class="cursor flex_1 dis al_item">
                      <el-form>
                        <el-form-item class="person-center-form-item">
                          <span class="form-item-title">当用户连续在</span>
                          <el-input-number v-model="params.settingBase.memberOverLoginInDays" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="天" size="mini" />
                          <span class="form-item-title">天内登录系统</span>
                          <el-input-number v-model="params.settingBase.memberOverLoginTimes" controls-position="right" class="flex-just" :max="360" :min="0" :precision="0" label="次" size="mini" />
                          <span class="form-item-title">次，通知平台管理员，通知方式：</span>
                          <el-checkbox-group v-model="params.settingBase.memberNotifyChannels" style="float: right;">
                            <el-checkbox :label="1">短信</el-checkbox>
                            <el-checkbox :label="2">邮件</el-checkbox>
                          </el-checkbox-group>
                        </el-form-item>
                      </el-form>
                    </div>
                  </div>
                </div>
              </div>
            </el-card>

          </div>

        </div>
      </div>
      <div class="btn-footer">
        <el-button>取消</el-button>
        <el-button type="primary" @click="submit">保存</el-button>
      </div>

    </el-main>
  </el-container>
</template>

<script>
import { logSettingView, logSettingSave } from '@/api/shoppingMall'
export default {
  components: {

  },
  data() {
    return {
      params: {
        settingBase: {
          tenantUserLogSaveYears: 7,
          tenantUserLogSaveMonths: 7,
          tenantUserLogSaveDays: 7,
          tenantUserNotLoginNotifyDays: 7,
          tenantUserNotLoginNotifyChannels: [1, 3],
          shopUserLogSaveYears: 7,
          shopUserLogSaveMonths: 7,
          shopUserLogSaveDays: 7,
          shopUserNotLoginNotifyDays: 7,
          shopUserNotLoginNotifyChannels: [1, 3],
          memberLogSaveYears: 7,
          memberLogSaveMonths: 7,
          memberLogSaveDays: 7,
          memberOverLoginInDays: 7,
          memberOverLoginTimes: 7,
          memberNotifyChannels: [1, 3]
        }
      }

    }
  },
  created() {
    this.getLogSettingView()
  },
  mounted() {
  },
  methods: {
    getLogSettingView() {
      logSettingView().then(res => {
        if (res.settingBase !== null) {
          this.params.settingBase = res.settingBase
        } else {
          this.$message.error(`读取日志基本配置出错`)
        }
      })
    },
    // 保存
    submit() {
      this.$confirm('确认要修改配置?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        logSettingSave(this.params).then(res => {
          if (res) {
            this.$message.success('保存成功！')
            this.getList()
          }
        })
      })
    }
  }
}
</script>

<style lang="scss">
 .setting_shopping-mall_inventory-set {
   background: #d8d8d8;
   padding: 4px;
   height: 90%;
   border-radius: 3px;
   overflow: auto;
   .clearfix{
     padding:5px;
     padding-top: 0;
     height: 15px;
     display: flex;
     align-items: center;
     >div {
       border: 0px solid #e6ebf5;
       flex-grow: 1;
       width:0;
       margin-right: 20px;
     }
   }
   }
   .fin-setting-content {
     width: 100%;
     margin: 0px 0 4px 4px;
     overflow-x: hidden;
     overflow-y: auto;
     border-radius:5px;
     .cardInfo {
         margin-top: 2px;
         padding: 2px;
      }
     .user-center-item {
       box-sizing: border-box;
       cursor: pointer;
       padding-bottom: 5px;
       &.active {
         border: 1px solid #1890ff
       }
     }

   }
   .nav-item {
     font-size: 14px;
     background: #ffffff;
     border: 0px solid #e3e2e5;
     border-radius: 4px;
     margin-bottom: 4px;
     width: 100%;
     display: inline-block;

     &:nth-child(odd) {
       margin-right: 10px;
       font-size: 14px;
       color: #595961;
     }

     .item-header {
       border-radius: 4px 4px 0 0;
       height: 55px;
       line-height: 20;
       padding: 0 10px 0 5px;
     }

     .item-content {
       padding: 5px 0;
     }
   }
   .person-center-form-item {
     font-size: 14px;
     width: 100%;
     display: flex;
     margin-left: 20px;
     .el-form-item__label, .el-form-item__content, .el-radio__label, .el-button, .el-checkbox .el-checkbox__label {
       font-size: 13px;
       color: #172161;
     }
     .el-input-number.is-without-controls.el-input__inner{
       width: 20px;
       height: 14px;
     }
     .el-input.is-without-controls.el-input__inner{
       height: 14px;
     }
     .form-item-input{
       min-height: 14px;
       width: 250px;
       font-size: 12px;
     }
     .form-item-title{
       padding-left: 1px;
       padding-right: 1px;
       color: #666;
     }
     .info-setting {
       margin-left: 15px;
       color: #0000FF;
       text-align: right;
       cursor: hand;
     }
     .flex-just{
       vertical-align: middle;
       width: 80px;
     }
   }
   .base-info {
     display: flex;
     .basics-info {
       margin: 0 auto;
     }
   }
   .el-form-item  {
     margin-bottom: 30px;
   }
   .el-col {
     margin-bottom: 0px;
   }
   .noMargin {
     margin-bottom: 0 !important;
   }
 .bg-white-panel {
   padding: 5px;
   font-size: 14px;
   font-weight: bolder;
   border-radius: 4px;
   margin-bottom: 5px;
 }

</style>
